

String WIFI_SCAN_JSON = "";
char*  AP_SSID = "guiyn-mark1";
IPAddress AP_LOCAL_IP(192, 168, 10, 1); //手动设置的开启的网络的ip地址
IPAddress AP_GATEWAY(192, 168, 10, 1); //手动设置的网关IP地址
IPAddress AP_SUBNET(255, 255, 255, 0); //手动设置的子网掩码

void startApServer() {
  WiFi.softAPConfig (AP_LOCAL_IP, AP_GATEWAY, AP_SUBNET);
  WiFi.softAP(AP_SSID);
  String mess = "Access Point[" + String(AP_SSID) + "] Setting IP[192.168.10.1]";
  Serial.println(mess);
  servletSet();
  
}

void servletSet() {
  server.on("/ws", HTTP_GET, userConfSet);
  String mess = "setter path=/ws";
  Serial.println(mess);
  server.onNotFound(notFound);
  server.begin();
}
void notFound(AsyncWebServerRequest *request) {
  request->send(404, "text/html", "not found");
}

void userConfSet(AsyncWebServerRequest * request)
{
  Serial.println("get input >>");
  UserConf conf = getUserConf();
  if (request->hasParam("sid")) {
    conf.sid = request->getParam("sid")->value();
  }

  if (request->hasParam("pass")) {
    conf.pass = request->getParam("pass")->value();
  }
  if (request->hasParam("wkey")) {
    conf.wather_key = request->getParam("wkey")->value();
  }
  if (request->hasParam("wloc")) {
    conf.localation = request->getParam("wloc")->value();
  }
  setUserConf(conf);

  saveJsonConf( CONF_FILE_NAME);
  request->send(200, "text/json", "success");
}
